import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Task extends ProjectItem{
	
	private Set<ProjectItem> projectItem;
	
	public Task(String name, String details, double rate){
		super(name, details, rate);
		projectItem=new HashSet<ProjectItem>();
	}
	
	public Set<Deliverable> allDeliverables(){
		HashSet<Deliverable> deliverables  = new HashSet<Deliverable>();
		for (ProjectItem item : projectItem) {
			if (item.getClass().getName().equals("Deliverable"))
			deliverables.add((Deliverable)item);
			else deliverables.addAll(item.allDeliverables());
		}
		return deliverables;
	}
	
	public double getTimeRequired(){
		double temp = 0;
		for(ProjectItem it : projectItem){
			temp=temp+it.getTimeRequired();
		}
		return temp;
	}
	
	public double getMaterialsCost(){
		double temp = 0;
		for(ProjectItem it : projectItem){
			temp=temp+it.getMaterialsCost();
		}
		return temp;
	}
	
	public void addProjectItem(ProjectItem pi){
		projectItem.add(pi);
	}
	
	public void removeProjectItem(ProjectItem pi){
		projectItem.remove(pi);
	}
	

}
